<h1 style="color:#FF3300;margin-bottom:10px">Hotel Manager</h1>
<select id="drdprovide" onchange="location.assign('<?php echo base_url(); ?>admin/hotel/index?provide='+$('#drdprovide').val());">
	<option value="0" <?php if(isset($_GET['provide'])){ if($_GET['provide']=="0") echo "disabled selected";}?>>Choice Destination</option>
	<option value="bagan" <?php if(isset($_GET['provide'])){ if($_GET['provide']=="bagan") echo "disabled selected";}?>>Bagan</option>
    <option value="inle" <?php if(isset($_GET['provide'])){ if($_GET['provide']=="inle") echo "disabled selected";}?>>Inle</option>
    <option value="mandalay" <?php if(isset($_GET['provide'])){ if($_GET['provide']=="mandalay") echo "disabled selected";}?>>Mandalay</option>
    <option value="yangon" <?php if(isset($_GET['provide'])){ if($_GET['provide']=="yangon") echo "disabled selected";}?>>Yangon</option>
</select>
<input type="text" id="searchname" value="" placeholder="Name..."/>
<?php
				$hotel_name="";
				for($i=0;$i<count($hotel);$i++){
					if($i!=(count($hotel)-1)) $hotel_name.= '"'.$hotel[$i]['name'].'",';
					else $hotel_name.= '"'.$hotel[$i]['name'].'"';			
			}?>
			<script>
				$(function() {
					var hotel_name = [
					<?php echo $hotel_name; ?>
					];
					$("#searchname").autocomplete({
					source: hotel_name
					});
				});
          </script>
<input type="button" value=" " style="border:1px solid #d5d5d5;cursor:pointer;background:url(<?php echo base_url() ?>public/images/iconsearch_submit.png) no-repeat center center #143167; padding:0 5px" id="btnsearch">
<input type="button" onclick="location.assign('<?php echo base_url(); ?>admin/hotel/edit');" value="Insert" style="float:right;margin-right:10px;margin-bottom:5px;"/>

<table cellpadding="0" cellspacing="0" id="listhotel">
	<tr>
    	<th>STT</th>
        <th>Name</th>
        <th>Star</th>
        <th>Address</th>
        <th>Type</th>
        <th>Destination</th>
        <th>Status</th>
        <th>Edit / Del</th>
        <th>Rooms</th>
        <th>Banner</th>
    </tr>
    <?php if(count($hotel)>0){ foreach($hotel as $k=>$listhotel){
			$type='';
			if($listhotel['category']==1) $type="Hotel - Wifi";
			if($listhotel['category']==2) $type="Hotel";
			if($listhotel['category']==3) $type="Hotel - Wifi in Public Area";
			if($listhotel['category']==4) $type="Resort";
			if($listhotel['category']==5) $type="Guest House";
		?>
		<tr>
            <th><?php echo $k+1; ?></th>
            <td><?php echo $listhotel["name"]; ?></td>
            <td align="center"><?php echo $listhotel["star"]; ?></td>
            <td><?php echo $listhotel["address"]; ?></td>
            <td><?php echo $type; ?></td>
            <td><?php echo $listhotel["provide"]; ?></td>
            <td><select id="status" onchange="location.assign('<?php echo base_url();?>admin/hotel/changestatus?<?php if(isset($_GET['provide']))echo "provide=".$_GET['provide']."&";if(isset($_GET['name'])) echo "name=".$_GET['name']."&";?>id=<?php echo $listhotel['id'] ?>&status='+$('#status').val());">
            		<option value="1" <?php if($listhotel['status']==1) echo "selected disabled";?>>Highlights</option>
                    <option value="2" <?php if($listhotel['status']==2) echo "selected disabled";?>>Normal</option>
                    <option value="3" <?php if($listhotel['status']==3) echo "selected disabled";?>>Hidden</option>
            </select></td>
            <th><a href="<?php echo base_url(); ?>admin/hotel/edit?id=<?php echo $listhotel['id'] ?>"><img src="<?php echo base_url(); ?>public/admin/img/icons/user_edit.png"/></a> / <a href="javascript:void(0);" name="btnDel" onClick="if(confirm('Do you want to Del this hotel is information ?')) location.assign('<?php echo base_url(); ?>admin/hotel/delete?id=<?php echo $listhotel["id"]; ?>');"><img src="<?php echo base_url(); ?>public/admin/img/icons/user_delete.png"/></a></th>
            <th><a href="<?php echo base_url(); ?>admin/hotelroom/index?hotelid=<?php echo $listhotel['id'] ?>">Rooms</a></th>
            <th><a href="<?php echo base_url(); ?>admin/hotelbanner/index?hotelid=<?php echo $listhotel['id'] ?>">Banner</a></th>
    	</tr>
	<?php }}?>    
</table>

<script>
	$('#searchname').click(function(){
		$('#searchname').removeClass('bxshadow_ff0000');								
	});
	$('#btnsearch').click(function(){
		if($('#searchname').val()==''){
			$('#searchname').addClass('bxshadow_ff0000');			
			return false;
		}else 
			<?php if(isset($_GET['provide'])){?>
				location.assign('<?php echo base_url(); ?>admin/hotel/index?provide=<?php echo $_GET['provide'] ?>&name='+$('#searchname').val());
			<?php }else{?>
				location.assign('<?php echo base_url(); ?>admin/hotel/index?provide=0&name='+$('#searchname').val());
			<?php }?>
	})
</script>